package com.vieewer.btdemo.common;
 
import android.app.Activity;
 
import java.lang.ref.WeakReference;
 
/**
 * Created by yjj
 */
 
public class MyActivityManager {
    
    private static MyActivityManager sInstance = new MyActivityManager();
    
    private WeakReference<Activity> sCurrentActivityWeakRef;
 
 
    private MyActivityManager() {
 
    }
 
    public static MyActivityManager getInstance() {
        return sInstance;
    }
 
    public Activity getCurrentActivity() {
        Activity currentActivity = null;
        if (sCurrentActivityWeakRef != null) {
            currentActivity = sCurrentActivityWeakRef.get();
        }
        return currentActivity;
    }
 
    public void setCurrentActivity(Activity activity) {
        sCurrentActivityWeakRef = new WeakReference<Activity>(activity);
    }
 
}